import BuffUtil from '@/BuffUtil';
import ItemUtil from '@/ItemUtil';
export default class Item_永世法衣 {
    static id = 'btst';
    static 名称: string = '永世法衣';
    static 描述: string = '提升魔法抗性';
    static 图标: string = 'assets\\item\\INV_Helm_Armor_Goblin_D_01.blp';
    static buffId: string = 'buff_item_yongshifayi';
    static buffType: AppBuffType = {
        id: 'buff_item_yongshifayi',
        name: Item_永世法衣.名称,
        ubertip: Item_永世法衣.描述,
        art: Item_永世法衣.图标,
        dur: 12,
        stackDurMode: true,
        stackCountMax: -1,
        attribute: {
            魔抗百分比: 0.15,
        },
        targetArt: 'Abilities\\Spells\\Undead\\AntiMagicShell\\AntiMagicShell.mdl',
        targetAttach: 'overhead',
    };
    // static 添加技能(目标: unit) {
    //     UnitAddAbility(目标, Item_永世法衣.id);
    // }
    // static 升级(u: unit) {
    //     IncUnitAbilityLevel(u, Item_永世法衣.id);
    // }
    // static 遗忘(u: unit) {
    //     UnitRemoveAbility(u, Item_永世法衣.id);
    // }
    static 释放(x: number, y: number, 来源?: unit, 目标?: unit, d?: any) {
        BuffUtil.addBuff(目标, Item_永世法衣.buffId, 来源);
    }
    static 伤害池: Map<unit, number> = new Map<unit, number>();
    constructor() {
        BuffUtil.registerBuffType(Item_永世法衣.buffType);
        // se.onUnitSpellEffect(Item_永世法衣.spellEffect, Item_永世法衣.id);
        EventManager.onTakeDamage(Item_永世法衣.spellEffect);
    }
    static spellEffect(d: DamageEventData) {
        if (!ItemUtil.isUnitHasItem(d.target, Item_永世法衣.id)) return;
        if (d.isPhysical) return;
        let dmg = Item_永世法衣.伤害池.get(d.target);
        if (!dmg) {
            dmg = d.lastDamage;
            Item_永世法衣.伤害池.set(d.target, d.lastDamage);
        } else {
            dmg += d.lastDamage;
            Item_永世法衣.伤害池.set(d.target, dmg);
        }
        if (dmg >= 500) {
            Item_永世法衣.伤害池.delete(d.target);
            Item_永世法衣.释放(0, 0, d.target, d.target, d);
        }
    }
}
